function Slideshow(config){
    var currentPosition = 0;
    var slideWidth = config.slideWidth;
    var slides = $('.' + config.slidesClass);
    var numberOfSlides = slides.length;

    $('#' + config.idSlidesContainer).css('margin', '0 auto');
    $('#' + config.idSlidesContainer).css('width', config.slideWidth + 'px');
    $('#' + config.idSlidesContainer).css('position', 'relative');
    $('#' + config.idSlidesContainer).css('overflow', 'hidden');


    $('.' + config.slidesClass).css('margin', '0 auto');
    $('.' + config.slidesClass).css('width', config.slideWidth - 20 + 'px');

    /*$('#leftControl' + config.idSlidesContainer + " , " +  '#rightControl' + config.idSlidesContainer)
        .css('margin-top', 'auto');
    $('#leftControl' + config.idSlidesContainer + " , " +  '#rightControl' + config.idSlidesContainer)
        .css('margin-bottom', 'auto');
    */

    // Wrap all .slides with #slideInner div
    slides
    .wrapAll('<div id="slideInner' + config.idSlidesContainer + '"></div>')
    // Float left to display horizontally, readjust .slides width
    .css({
        'float' : 'left',
        'width' : slideWidth
    });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner' + config.idSlidesContainer).css('width', slideWidth * numberOfSlides);

    // Insert left and right arrow controls in the DOM
    $('#' + config.slideParent)
    .prepend('<image class="control leftControl" id="leftControl' + config.idSlidesContainer + '" src="plugins/slideshow/img/left.jpg"/>')
    .append('<image class="control rightControl" id="rightControl' + config.idSlidesContainer + '" src="plugins/slideshow/img/right.jpg"/>');

    // Hide left arrow control on first load
    manageControls(currentPosition);

    // Create event listeners for .controls clicks
    $('#leftControl' + config.idSlidesContainer + " , " +  '#rightControl' + config.idSlidesContainer)
    .bind('click', function(){
        // Determine new position
        currentPosition = ($(this).attr('id')=='rightControl' + config.idSlidesContainer)
        ? currentPosition+1 : currentPosition-1;

        // Hide / show controls
        manageControls(currentPosition);
        // Move slideInner using margin-left
        $('#slideInner' + config.idSlidesContainer).animate({
            'marginLeft' : slideWidth*(-currentPosition)
        });
    });

    // manageControls: Hides and shows controls depending on currentPosition
    function manageControls(position){
        // Hide left arrow if position is first slide
        if(position==0){
            $('#leftControl' + config.idSlidesContainer).hide()
        }
        else{
            $('#leftControl' + config.idSlidesContainer).show()
        }
        // Hide right arrow if position is last slide
        if(position==numberOfSlides-1){
            $('#rightControl' + config.idSlidesContainer).hide()
        }
        else{
            $('#rightControl' + config.idSlidesContainer).show()
        }
    }

    this.mostrarBotonesDeDesplazamiento = function(){
        manageControls(currentPosition);
    }

    this.getCurrentPosition = function (){
        return currentPosition;
    };
}